// 创建vue对象
var vm = new Vue({
    el: "#allBook",
    data(){
        return{
            books: null,
            queryBookName: null
        }
    },
    mounted(){
        // 发起请求
        axios.get("/books/find_all")
            .then(resp => {
                this.books = resp.data;
            })
            .catch(error => (console.log(error)))

    },
    methods: {
        selectBook(){
            // 发起请求
            axios.get("/books/find_by_name/" + this.queryBookName)
                .then(resp => {
                    this.books = resp.data
                })
                .catch(error => (console.log(error)))
        },
        deleteBook(id){
            // 发起请求
            axios.get("/books/del/" + id)
                .then(resp => {
                    window.location.reload()
                })
                .catch(error => (console.log(error)))
        },
        updatePage(id){
            window.location.replace("/books/updateBook.html");
            window.sessionStorage.setItem("id", id)
        }
    }
});